﻿using MaximServices.Model;
using MaximServices.Repository;
using System;
using System.Collections.Generic;
using System.Text;

namespace MaximServices.Services
{
    public class SysuserServices
    {
        private SysuserRepository _sysuserRepository;
        private MottoRepository _mottoRepository;
        private MottoServices _mottoServices;

        public SysuserServices(SysuserRepository sysuserRepository,MottoRepository mottoRepository, MottoServices mottoServices)
        {
            _sysuserRepository = sysuserRepository;
            _mottoRepository = mottoRepository;
            _mottoServices = mottoServices;
        }

        public ResultModel<LoginResultModel> GetModel(string name, string mockDate)
        {
            Sysuser model = _sysuserRepository.GetModel(name);
            if(null != model)
            {
                return BuildResult.Success(new LoginResultModel
                {
                    userInfo = model,
                    motto = _mottoServices.GetSingleMotto(model.Id, mockDate)
                });
            }
            else
            {
                return BuildResult.Error("用户名密码错误", default(LoginResultModel));
            }
        }
    }
}
